package com.fc.hkx.process.migrate;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * the dialect is an instance everything we need to know to do database specific
 * tasks.
 * 
 * @author Chris
 */
public interface Dialect {
    
    /**
     * the name of the RS4 version table
     */
    String DEFAULT_VERSION_TABLE_NAME = "RS4_VERSION";
    
    /**
     * the name of the column in the 
     */
    String VERSION_COLUMN_NAME = "DB_VERSION";


    /**
     * @param conn
     * @return true if the version table exists
     */
    boolean hasVersionTable(Connection conn, String versionTable) throws SQLException;
    
    
    /**
     * create's the version table
     * 
     * @param conn
     * @throws SQLException
     */
    void createVersionTable(Connection conn, String versionTable) throws SQLException;
    
    
    /**
     * selects the version from the version table, may return none if there
     * is no entry.
     * 
     * @param conn
     * @return
     * @throws SQLException
     */
    int getVersion(Connection conn, String versionTable) throws SQLException;
    
    /**
     * set's the version in the version table.
     * 
     * @param conn
     * @param version
     * @throws SQLException
     */
    void setVersion(Connection conn, int version, String versionTable) throws SQLException;
    
    /**
     * executes the specified sql ddl
     * 
     * @param sql
     * @param conn
     * @throws SQLException
     */
    void executeSql(Connection conn, String sql) throws SQLException;

}
